import java.util.Arrays;
import java.util.Comparator;

/**
 * @Author ZhangCuirong
 * @Date 2025/9/5 9:08
 * @description:
 */
public class Solution179 {
    public String largestNumber(int[] nums) {
        String [] strings = new String[nums.length];
        for (int i = 0; i < nums.length; i++) {
            strings[i] = String.valueOf(nums[i]);
        }
        Arrays.sort(strings, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return (o2+o1).compareTo(o1+o2);
            }
        });
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < strings.length; i++) {
            result.append(strings[i]);
        }
        if(strings[0].equals("0")){
            return "0";
        }
        return result.toString();
    }

    public static void main(String[] args) {
        Solution179 solution = new Solution179();
        System.out.println(solution.largestNumber(new int[]{10,2}));
        System.out.println(solution.largestNumber(new int[]{3,30,34,5,9}));

    }
}
